//
//  UIView+Extension.h
//  iTrends
//
//  Created by fanrui on 12-9-3.
//
//

#import <UIKit/UIKit.h>


@interface UIView (Extension)
-(CGFloat)height;
-(void)setHeight:(CGFloat)height;
-(void)setHeight:(CGFloat)height Animated:(BOOL)animate;
-(void)addHeight:(CGFloat)height;

-(CGFloat)right;
-(CGFloat)bottom;

- (void)shake;

- (CGFloat)center_Y;
- (CGFloat)center_X;
- (void)setCenter_Y:(CGFloat)y;
- (void)setCenter_X:(CGFloat)x;


-(CGFloat)width;
-(void)setWidth:(CGFloat)width;
-(void)setWidth:(CGFloat)width Animated:(BOOL)animate;
-(void)addWidth:(CGFloat)width;

-(CGFloat)originX;
-(void)setOriginX:(CGFloat)x ;
-(void)setOriginX:(CGFloat)x Animated:(BOOL)animate;
-(void)addOriginX:(CGFloat)x;

-(CGFloat)originY;
-(void)setOriginY:(CGFloat)y;
-(void)setOriginY:(CGFloat)y Animated:(BOOL)animate;
-(void)addOriginY:(CGFloat)y;

-(CGSize)size;
-(void)setSize:(CGSize)size;
-(void)setSize:(CGSize)size Animated:(BOOL)animate;

-(CGPoint)origin;
-(void)setOrigin:(CGPoint)point;
-(void)setOrigin:(CGPoint)point Animated:(BOOL)animate;


- (UIView * (^)(CGFloat))cornerRadius;
- (UIView * (^)(CGFloat))borderWidth;
- (UIView * (^)(UIColor *))borderColor;
- (BOOL)shadowOff;
- (void)setShadowOff:(BOOL)shadowOff;

/**
 元素的右上角的点
 */
-(CGPoint)originTopRight;
/**
 元素的左下角的点
 */
-(CGPoint)originBottomLeft;
/**
 元素的右下角的点
 */
-(CGPoint)originBottomRight;

-(CGRect)rectForCenterofSize:(CGSize)size;//居中一个size
/*
 返回该类中所有指定类型的subview
 */
-(NSArray*)subviewsWithClass:(Class )cls;



#pragma mark -
#pragma mark -xib
/**
 从xib加载控件
 需要将xib的file's owner设置为self
 @param frame:视图的大小
 @param nibNameOrNil:要加载的xib名称，默认为类名
 @return 返回加载后的视图
 */
-(id)initWithFrame:(CGRect)frame nibNameOrNil:(NSString*)nibNameOrNil;
+(instancetype)loadViewForNib;

+(instancetype)loadViewForNibWithName:(NSString *)name;
/**
 转换图片

 @return
 */
-(UIImage *)convertViewToImage;


/**
 切圆角（头像，按钮切成圆形，直接调用下这个方法即可）
 */
- (void)cutRoundView;

/**
 截屏UIView
 @return 截屏图片
 */
- (UIImage *)captureView;
@end
